<template>
    <div style="padding:30px;">
        <el-alert :closable="false" title="">
            <transition name="fade-transform" mode="out-in">
                <template>
                    <div class="serverRoot" v-if="serverModel != null">
                        <div>
                            <el-card class="box-card">
                                <div slot="header" class="clearfix">
                                    <span>服务器基本信息</span>
                                </div>
                                <div class="serverinfo">
                                    <div>
                                        <div class="info">
                                            <div>服务器名称</div>
                                            <div>{{ serverModel.serverInfo.hostname }}</div>
                                        </div>
                                        <div class="info">
                                            <div>操作系统</div>
                                            <div>{{ serverModel.serverInfo.goos }}</div>
                                        </div>
                                    </div>
                                    <div>

                                        <div class="info">
                                            <div>服务器版本</div>
                                            <div>{{ serverModel.serverInfo.version }}</div>
                                        </div>
                                        <div class="info">
                                            <div>开机时间</div>
                                            <div>{{ new Date(serverModel.serverHost.bootTime * 1000).toLocaleString() }}
                                            </div>
                                        </div>
                                    </div>
                                    <div>
                                        <div class="info">
                                            <div>服务器IP</div>
                                            <div>{{ serverModel.serverInfo.ip }}</div>
                                        </div>
                                        <div class="info">
                                            <div>内核版本</div>
                                            <div>{{ serverModel.serverHost.kernelVersion }}</div>
                                        </div>
                                    </div>


                                </div>
                            </el-card>
                        </div>

                        <div class="cpuinfo">
                            <el-card class="box-card">
                                <div slot="header" class="clearfix">
                                    <span>CUP</span>
                                </div>
                                <div v-for="o in 4" :key="o" class="text item">
                                    {{ '列表内容 ' + o }}
                                </div>
                            </el-card>
                            <el-card class="box-card">
                                <div slot="header" class="clearfix">
                                    <span>内存</span>
                                </div>
                                <div v-for="o in 4" :key="o" class="text item">
                                    {{ '列表内容 ' + o }}
                                </div>
                            </el-card>
                        </div>
                        <div class="diskinfo">
                            <el-card class="box-card">
                                <div slot="header" class="clearfix">
                                    <span>磁盘</span>
                                </div>
                                <div v-for="o in 8" :key="o" class="text item">
                                    {{ '列表内容 ' + o }}
                                </div>
                            </el-card>
                        </div>
                    </div>
                </template>
            </transition>
        </el-alert>
    </div>
</template>
<style>
.serverRoot {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.serverRoot>div {
    width: 100%;
}

.serverinfo {
    display: flex;
    flex-direction: column;
    height: 150px;
    width: 100%;
    font-size: 16px;
}

.serverinfo>div {
    display: flex;
    flex-direction: row;
    flex: 1;
    width: 100%;
    justify-content: space-between;
}

.info {
    display: flex;
    flex-direction: row;
    /* justify-content: space-between; */
    width: 100%;
}

.info>div {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 50%;
}


.cpuinfo {
    display: flex;
    flex-direction: row;
    gap: 10px;
    height: 200px;
}

.cpuinfo .box-card {
    width: 50%;
}


.diskinfo {
    height: 250px;
}
</style>

<script lang="ts">
import { IServerModel } from '@/api/types';
import { ServerModule } from '@/store/modules/server';
import { Component, Vue } from 'vue-property-decorator'

@Component({
    name: 'Server',
    components: {
    }
})
export default class extends Vue {
    public serverModel: any = null;
    public listLoading: boolean = false
    public size: string = ""

    mounted() {
        // console.error(queue);
    }
    created() {
        this.init()
    }

    public async init() {
        this.serverModel = null;

        this.listLoading = true
        let result: any = await ServerModule.getServers()
        this.serverModel = result
        console.error(this.serverModel)
        setTimeout(() => {
            this.listLoading = false
        }, 0.5 * 1000)
    }
}
</script>